<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<?php 
	session_start(); 
	include "../User_access/access_eleve.php";
	include 'includes/bandeau_sup.php';
?>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
		<link href='http://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700' rel='stylesheet' type='text/css'>
		<link href='http://fonts.googleapis.com/css?family=Source+Sans+Pro' rel='stylesheet' type='text/css'>
		<link rel='stylesheet' href='includes/style.css' />
	</head>
	
	<body>
	<header>
		<h1>Consultation de la table des compétences</h1>
	</header>
	<div id='bloc_page'>
	<section>
		<article style='text-align:center;border-bottom:1px solid black;'><?php if (isset($_SESSION['user']['message'])) {echo "<img src='/img/error.png' /> - ".$_SESSION['user']['message']; unset($_SESSION['user']['message']);} ?></article>
		<article>
					<p>
						<?php
							include "../conf/config.php";

							$db_name="website"; // Database name 
							$nom=$_SESSION['user']['Nom'];

							// Connect to server and select databse.
							$result = mysql_connect($host,$granted_user,$granted_mdp)or die("impossible de se connecter"); 
							$result = mysql_select_db("$db_name")or die("ne peut selectioner DB");
							if (!$result) {
 								$message  = 'Requête invalide : ' . mysql_error() . "\n";
								$message .= 'Requête complète : ' . $query;
								die($message);
							}
							else {
								$sql="SELECT evo.progression, comp.nomComp, evo.id_evo
								FROM comp, evo, user
								WHERE '$nom'= user.Nom 
								AND evo.id_comp=comp.id_comp
								AND evo.id_user=user.id_user
								AND user.valide = 1";
								// echo $sql;
								$query=mysql_query($sql);
								echo "<table><form method='POST' action='modify_student.php' name='form_modif'>";
								while($row = mysql_fetch_array($query))
								{
									echo "<tr> <input name='old_skill[".$row['id_evo']."]' type='hidden' value='".$row['progression']."' /><td>".$row['nomComp'] . "</td><td>Ancienne valeur : " .$row['progression'] . "%</td><td>Nouvelle valeur : 
										<select name='new_skill[".$row['id_evo']."]' id='new_skill_".$row['id_evo']."' required>";
									
									foreach (array(0, 25, 50, 75, 100) as $val) {
										echo "<option value='$val'";
									
										if ($val == $row['progression']) {
											echo " selected";
										}  

										echo ">$val %</option>";
									}

									echo "</select></td></tr>";
								} 
								echo "</table><input type='submit' name='modify' /></form>";
							}
						?>
					</p>

		</article>		
		<article>
			<p><a href="index.php">Revenir au menu</a></p>
		</article>
	</section>
	</div>
	<?php include "includes/footer.php" ?>
	</body>
</html>